﻿using System;
using System.Windows;

using SBPweb.PROvibe.Shared.Library.Components;

namespace SBPweb.PROvibe.Client.Library.Base
{

    public class UserControlBase : SBPweb.RIA.Client.Controls.Base.UserControlBase
    {

        #region Constructor logic

        protected UserControlBase()
            : base()
        {
            ClientContext = new ClientContext(this.GetType());
            InitializeHandlers();
        }

        #endregion

        #region Property accessors

        public ClientContext ClientContext
        {
            get;
            private set;
        }

        #endregion

        #region Methods

        protected override void InitializeHandlers()
        {
            if (Application == null || Application.IsDesignTime)
            {
                return;
            }
            Loaded += new RoutedEventHandler(OnLoaded);
            Unloaded += new RoutedEventHandler(OnUnloaded);
        }

        protected override void FinalizeHandlers()
        {
            Loaded -= new RoutedEventHandler(OnLoaded);
            Unloaded -= new RoutedEventHandler(OnUnloaded);
        }

        protected override void OnLoaded(object sender, RoutedEventArgs e)
        {
        }

        protected override void OnUnloaded(object sender, RoutedEventArgs e)
        {
            FinalizeHandlers();
        }

        #endregion

    }

}